<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>视频播放测试</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
            background: #f0f0f0;
        }
        .test-container {
            max-width: 800px;
            margin: 0 auto;
            background: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        .test-btn {
            background: #007bff;
            color: white;
            border: none;
            padding: 10px 20px;
            margin: 5px;
            border-radius: 5px;
            cursor: pointer;
        }
        .test-btn:hover {
            background: #0056b3;
        }
        iframe {
            width: 100%;
            height: 400px;
            border: 1px solid #ddd;
            border-radius: 5px;
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <div class="test-container">
        <h1>视频播放器测试</h1>
        <p>点击下面的按钮测试不同的视频播放功能：</p>
        
        <button class="test-btn" onclick="testVideo1()">测试视频1 (MP4)</button>
        <button class="test-btn" onclick="testVideo2()">测试视频2 (WebM)</button>
        <button class="test-btn" onclick="testVideo3()">测试视频3 (自动播放)</button>
        <button class="test-btn" onclick="clearVideo()">清除视频</button>
        
        <iframe id="testFrame" src="index.html"></iframe>
    </div>

    <script>
        const iframe = document.getElementById('testFrame');
        
        function sendVideoMessage(videoData) {
            iframe.contentWindow.postMessage({
                type: 'video',
                data: videoData
            }, '*');
        }
        
        function testVideo1() {
            sendVideoMessage({
                type: 'video',
                url: 'https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4',
                autoplay: true,
                muted: true,
                duration: 0
            });
        }
        
        function testVideo2() {
            sendVideoMessage({
                type: 'video',
                url: 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
                autoplay: false,
                muted: false,
                duration: 0
            });
        }
        
        function testVideo3() {
            sendVideoMessage({
                type: 'video',
                url: 'https://sample-videos.com/zip/10/mp4/SampleVideo_640x360_1mb.mp4',
                autoplay: true,
                muted: true,
                duration: 0
            });
        }
        
        function clearVideo() {
            sendVideoMessage({
                type: 'clear'
            });
        }
        
        // 监听来自iframe的消息
        window.addEventListener('message', (event) => {
            if (event.source === iframe.contentWindow) {
                console.log('收到iframe消息:', event.data);
            }
        });
    </script>
</body>
</html> 